home *** CD-ROM | disk | FTP | other *** search
/ The 640 MEG Shareware Studio 2 / The 640 Meg Shareware Studio CD-ROM Volume II (Data Express)(1993).ISO / batch / strings2.zip / STRINGS.DOC < prev    next >
Text File  |  1992-11-25  |  49KB  |  1,080 lines

  1. STRINGS.COM  (Version 2.0)        Copyright (c) 1991, 1992 Douglas Boling
  2. -------------------------------------------------------------------------
  3.               First Published in PC Magazine December 22, 1992 (Utilities)
  4. -------------------------------------------------------------------------
  5.  
  6. STRINGS:
  7.  
  8.         The original STRINGS.COM removed the restrictions imposed by the DOS
  9. batch file language to give your batch files more versatility. This upgraded
  10. TSR version enhances a number of the original functions and implements more
  11. than 35 new ones.
  12.  
  13.  
  14. Batch Files Get Even Better With Our STRINGS 2.0
  15. BY DOUGLAS BOLING
  16.  
  17.     The new version contains not only the batch file commands of the
  18. original utility, but 6 enhanced functions and 35 new ones as well.
  19. In all, as shown in Figure 1 (below) STRINGS now adds about 70 commands
  20. to the batch file language. (Some of these commands can be used from
  21. the DOS prompt as well.) Where the original STRINGS let you add a series
  22. of numbers, read a line from a file, or ask a user a question,
  23. STRINGS 2.0 includes additional functions that allow batch files to
  24. query the date and time, get the current country and codepage, and even
  25. read and write to memory locations.
  26.  
  27.      Perhaps the outstanding new feature of STRINGS 2.0 is that under
  28. DOS 3.3 or later it can now act as an extension to the DOS command
  29. processor, COMMAND.COM.  This required rewriting the program so it could
  30. become a TSR.
  31.      Once memory resident, since COMMAND.COM no longer has to search,load, and run the program, STRINGS's commands execute with the same speed
  32. as do such internal COMMAND.COM functions as COPY, RENAME, and DELETE.
  33.  
  34.      The new program itself bears the same name, STRINGS.COM, as its
  35. predecessor.  That allows you to upgrade instantly simply by copying the
  36. new program over the old. To avoid confusion, I will refer to the original
  37. version of the utility as STRINGS1. If you have never used STRINGS1,
  38. reading through the original article will be helpful, but I'll try to
  39. explain enough here to make that unnecessary.
  40.  
  41.     To assemble the source you will need an assembler compatible with
  42. Microsoft's MASM 2.0.  The commands to create STRINGS.COM are:
  43.  
  44.                              MASM STRINGS;
  45.                              LINK STRINGS;
  46.                              EXE2BIN STRINGS STRINGS.COM
  47.  
  48.  
  49. USING STRINGS
  50.  
  51.      At first sight, the complete syntax for STRINGS.COM may seem
  52. dauntingly complex:
  53.  
  54.      STRINGS [/?][/M][/Q][/Pc][/Bn][/I][/U] [env var =] FUNCTION [Params]
  55.  
  56. But it's a lot easier to use than it looks.  One reason is that, in
  57. addition to this article, the on-screen help facilities are extensive.
  58. Simply enter STRINGS at the DOS prompt and you'll get an explanation of
  59. every item in the syntax line above. Entering STRINGS /? will give you a
  60. complete list of all the commands denoted by FUNCTION, and
  61.  
  62.                            STRINGS /? FUNCTION
  63.  
  64. will spell out the purpose, usage, and Prams (parameters) of each
  65. individual command.  Note that in both of these last two commands the
  66. /? can be replaced by /HELP.
  67.  
  68.     Many STRINGS commands require no arguments; for these you just enter
  69.  
  70.                            STRINGS FUNCTION
  71.  
  72. For example, to return the last available drive letter you simply enter:
  73.  
  74.  
  75.                            STRINGS LASTDRIVE
  76.  
  77. STRINGS will respond by displaying the last available drive letter on
  78. your system.
  79.  
  80.     For commands that do take input parameters, the arguments are
  81.  separated by commas.  For example, the command LEFT, which returns the
  82. first n characters (including spaces) of a string, has two parameters:
  83. the input string and the number of characters to return.  Thus,
  84.  
  85.  
  86.                            STRINGS LEFT This is a string, 9
  87.  
  88. will return the left nine characters ``This is a".  Note the comma
  89. separating the two parameters in the command line.
  90.  
  91.     The results of any STRINGS command can be assigned to an environmentvariable.  Simply insert the name for the variable and an equals sign
  92. between STRINGS and FUNCTION.  For example, by changing the previous
  93. example to
  94.  
  95.  
  96.                            STRINGS ANSWER =LEFT This is a string, 9
  97.  
  98. STRINGS will assign the string ``This is a'' to the environment variable
  99. ANSWER.
  100.  
  101.     As shown above, STRINGS has seven command line switches:
  102. /M, /Pc, /Q, /Bn, /I, /U and /?.  The switch must be included on the
  103. command line before the environment variable or, if no variable is
  104. specified, before the command.
  105.  
  106.     By default, STRINGS stores variables in the Active environment,
  107. which is created by the current copy of COMMAND.COM.  If the /M switch
  108. is used, however, STRINGS stores variables in the master environment,
  109. which is created by COMMAND.COM when DOS starts.
  110.  
  111.     In Windows, while each DOS box has its own Active environment, all
  112. share the Master environment.  By using the /M switch, variables can be
  113. read by all programs, including those in individual Windows DOS boxes.
  114. The /M switch is also useful when you want to preserve a variable
  115. assignment you make while shelled out from a program, for the local
  116. environment is lost when you exit from DOS back into your application.
  117.  
  118.     Reverting to the previous example, to assign the results to the
  119. environment variable RESULT in the Master environment, the command would
  120. be
  121.  
  122.                    STRINGS /M RESULT = LEFT This is a string, 9
  123.  
  124.     The MASTERVAR command returns the string assigned to a variable inthe Master environment.  For example, the command
  125.  
  126.                           STRINGS MASTERVAR RESULT
  127.  
  128. returns the string assigned to the RESULT environment variable even if
  129. this command is executed in a different DOS box from the one that was
  130. used in previous examples!
  131.  
  132.      The /Pc (or Parse) switch tells STRINGS to use the c character
  133. rather than the comma to separate multiple parameters.  This switch
  134. allows you to work with strings that contain commas.
  135.  
  136.     The /Q (or Quiet) switch, which was added in a maintenance release
  137. of STRINGS 1.0, prevents STRINGS from writing to the screen. This switch
  138. is useful if the STRINGS command may produce an error message that you
  139. don't want displayed on the screen.
  140.  
  141.     New in STRINGS 2.0 is the /Bn switch, which is used to change the number
  142. base that STRINGS uses to interpret numbers. STRINGS defaults to base 10
  143. arithmetic, but by using the /B switch, you can set the base to any number
  144. from 2 to 16.  Thus, while the statement
  145.  
  146.                                          STRINGS ADD 9, 1 
  147.  
  148. returns the standard value 10, the statement
  149.  
  150.                                          STRINGS /B16 ADD 9, 1 
  151.  
  152. returns the ``number'' A, since A in hexadecimal (base 16) is 10 in decimal.
  153. You'll want to use the /B switch working with several of the new STRINGS
  154. commands, where it is more appropriate to use hexadecimal than decimal
  155. numbers.
  156.  
  157.     If your system is running DOS 3.3 or later, using the /I switch installs
  158. STRINGS as a resident extension of COMMAND.COM.  (How STRINGS actuallyaccomplishes this will be discussed later.) Unlike most TSRs, which are
  159. installed at startup, STRINGS works best if it is installed only when
  160. and for as long as needed; it should be removed from memory once the
  161. batch file has completed in order to avoid wasting valuable systemmemory.  To uninstall STRINGS, you simply use the /U switch.
  162.  
  163.     Installing STRINGS as a resident extension does not alter the syntax
  164. of any of its commands. The speed advantage is dramatic. The disadvantage,
  165. however, is that once installed, STRINGS (like all internal COMMAND.COM
  166. commands) cannot return an exit code to COMMAND.COM. This means that
  167. while STRINGS is resident, you can't use the handy IF ERRORLEVEL statement
  168. in .BAT files to test the result of STRINGS commands.
  169.  
  170.     If your batch file requires the error level codes returned by STRINGS,
  171. two solutions are available.  The first and most obvious is simply not
  172. to install STRINGS at the start of the batch file.  When not installed,
  173. STRINGS 2.0 returns the same error codes as STRINGS 1.0.
  174.  
  175.     The second solution is to specify explicitly the full path to theSTRINGS.COM file.  When a complete path is specified the resident copy
  176. of STRINGS will ignore the command, thus allowing COMMAND.COM to launch
  177. a second copy of STRINGS as a transient program.  For example, since I
  178. keep STRINGS in my UTIL directory, I can force COMMAND.COM to launch a
  179. second copy of STRINGS with the command:
  180.  
  181.  
  182.                               C:\UTIL\STRINGS sub 12, 15 
  183.  
  184.      The use of the
  185.  
  186.                               /?
  187.  
  188. and
  189.  
  190.                               /? FUNCTION
  191.  
  192. switches to obtain on-line help was discussed earlier.  It should be noted
  193. that on-line help is not available when STRINGS is installed in memory,
  194. since the help text would take up an additional 4,500 bytes of memory.
  195. To get help for a specific command while STRINGS is installed, simply
  196. specify the full path to force execution of a nonresident copy of STRINGS.
  197.  
  198. STRINGS COMMANDS
  199.  
  200.      Providing a detailed explanation of the 70 functions shown in
  201. Figure 1 (see below) is not easy, so I've divided them into 6 groups:
  202. old commands enhanced for STRINGS 2.0, string handling, programmer's, data
  203. and time, system memory, and STRINGS management commands.
  204. The /? FUNCTION help screen will suffice for the functions in STRINGS1 if
  205. you haven't got access to the original article. (A copy of the original
  206. article (STRING1.DOC) is included in the archive STRING.ZIP).
  207.  
  208.     Six commands from STRINGS1 have been enhanced:  CHAR, VAL, ASK,
  209. ADD, SUB, and MUL.  In STRINGS1, the CHAR command was limited to
  210. returning the single ASCII character that corresponded to a decimalnumber.  Now in STRINGS, CHAR can take up to ten parameters, so ten
  211. numbers can be converted into ten ASCII characters.
  212. For example, the command 
  213.  
  214.                           STRINGS CHAR 65, 66, 67 
  215.  
  216. returns the string ABC.
  217.  
  218.     The VAL command has been similarly enhanced.  An ASCII string passedto VAL will produce the series of up to ten decimal numbers that correspond
  219. to the characters in the string. The numbers will be separated by spaces.
  220. For example, the command 
  221.  
  222.                          STRINGS VAL Doug
  223.  
  224. returns the string
  225.  
  226.                          68 111 117 103
  227.  
  228. When appropriate, this format can easily be converted into a series of
  229. hex bytes by using the /B16 switch.  Note that because the capital and
  230. small letters have different ASCII values, VAL is inherently case-sensitive.
  231.  
  232.     The enhanced ASK function prints a string and waits for the user to
  233. enter a response.  Its full syntax is: 
  234.  
  235. STRINGS [dest var =] ASK [Prompt string][,Max chars][,1=* echo 2=No echo]
  236.  
  237.    After entering the Prompt string as the first parameter, you specify
  238. the maximum number of characters the user can use to respond as the second.
  239. The maximum can be any number between 1 and 127. Although STRINGS works
  240. with strings up to 127 characters long, remember that DOS programs can only
  241. accept a command line with a total length of 127 characters.  Thus,
  242. setting an environment variable to a long length may cause DOS to overflow
  243. the command line of a program that uses that variable.
  244.  
  245.     The third and final ASK parameter is a flag that tells STRINGS not
  246. to echo what the user types to the screen.  This allows a .BAT file to
  247. prompt for a password without its becoming visible on the screen.
  248. When the third parameter is a 1, STRINGS echoes asterisks to the screenin place of the characters being typed.  If the parameter is 2, STRINGS 
  249. does not echo any characters to the screen. If neither flag is specified,
  250. the user response is echoed.
  251.  
  252.     Three of the math functions--ADD, SUB, and MUL--have been revised toallow you to add or multiply up to 10 different numbers in one STRINGS
  253. command.  For the SUB command, up to nine numbers can be subtracted from
  254. the first number in the series.  Thus, the command 
  255.  
  256.                                  STRINGS SUB 10, 2, 1 
  257.  
  258. returns the value 7, which is computed as 10 - 2 - 1.
  259.  
  260. STRING HANDLING COMMANDS
  261.  
  262.         This first set of the new STRINGS commands goes to the root of the
  263. program's functionality; its ability to manipulate strings.
  264.  
  265.     The PARSE command separates a string into different sections and
  266. returns one of those sections.  This command makes it easy to separate
  267. the different directory strings from the PATH environment variable, for
  268. example.  The full syntax for PARSE is
  269.  
  270. STRINGS [dest var =] PARSE String, section number, Separator char
  271.  
  272. The three PARSE parameters are the string, the section number to return,
  273. and the separator character to be used to differentiate among sections.
  274. The small batch file, CHECKEX.BAT, (listed below in Figure 2) uses the
  275. PARSE command to search the PATH to determine the execution order of the
  276. program name you provide. This is exactly what COMMAND.COM does when it
  277. is asked to launch a program. On my machine, the command 
  278.  
  279.                            CHECKEX brief
  280.  
  281. returned the list
  282.  
  283.                            C:\UTIL\B.BAT
  284.                            C:\EDITORS\BRIEF\B.EXE
  285.  
  286. This return discloses a problem:  If DOS searches the full path, B.BAT
  287. will execute, but B.EXE never will. It seems I should rename that batch
  288. file!
  289.  
  290.     As shown by the STRINGS line in CHECKEX.BAT, the PARSE command here
  291. uses the PATH environment variable as the starting string. It uses theINDEX environment variable to run through the different directories in
  292. sequence. And it uses the semicolon to tell where one directory ends
  293. and the next one begins on the PATH statement.
  294.  
  295.     ADDCOMMAS is a simple command that inserts commas every three digits in
  296. a number you supply as its argument.  If you enter
  297.  
  298.                            STRINGS ADDCOMMAS 12345678
  299.  
  300. STRINGS will return
  301.  
  302.                            12,345,678
  303.  
  304.     The REPEAT command simply creates a string that consists of the
  305. same character repeated n times.  For example, the command
  306.  
  307.                             STRINGS REPEAT 25, A
  308.  
  309. will return a string with 25 As.  The maximum value for n is 127.
  310.  
  311.     The FILEDATE command returns the date on a file. It takes filename
  312. as its only argument, and the date is returned in a mm-dd-yyyy format.
  313. The FILETIME command similarly returns the time when a file was last
  314. written, in a hh:mm:ss am/pm format.
  315.  
  316.     TRUEVER returns the true DOS version number, regardless of what is
  317. reported by the normal VER command.  With the introduction of the SETVER
  318. device driver in DOS 5.0, you can trick programs into believing that theyare running under a different version of DOS than they actually are.
  319. There are times, however, when you need to know the real DOS version:
  320. hence TRUEVER.  The number returned is the major version number times100, plus the minor version number.  For example, in DOS 5.0 the number
  321. returned is 500.
  322.  
  323.     Although the SETVER device driver is only available on DOS 5.0
  324. (and later), the TRUEVER command will still work under DOS versions 2.0
  325. though 4.0; it simply returns the same value as does the STRINGS VER
  326. command.
  327.  
  328.     The FILES command returns the maximum number of files that can be
  329. open on the system at one time.  This number is usually, but not always,
  330. the number shown in the FILES= statement in your CONFIG.SYS file.
  331. Programs such as Windows or Jeff Prosise's UMBFILES can change the
  332. maximum number of files, however, so FILES is a handy way to confirm
  333. that a program will have enough file handles to run.
  334.  
  335.     The LASTDRIVE command returns the last drive letter that can be
  336. assigned to a disk.  This is usually set with the LASTDRIVE= line in
  337. the CONFIG.SYS file, but again, some programs can modify that value.
  338. LASTDRIVE is useful when a batch file must perform an action on all
  339. possible drives in the system.
  340.  
  341.     The CODEPAGE command allows batch files to determine the currently
  342. active codepage.  The codepage number determines the character set your
  343. system uses.  Most US systems use codepage 437, which is the standard
  344. character set. Codepage 850, on the other hand, replaces some of the
  345. graphic characters in the 437 codepage with characters used in European
  346. languages. To query the active codepage, simply enter STRINGS CODEPAGE.
  347.  
  348.     The COUNTRY command returns the country information for the system.Since DOS 2.0, parameters such as the currency symbol, thousands separator,
  349. and the date format can be configured for different countries. The table
  350. in Figure 3 (see below) shows what the COUNTRY command returns for
  351. different values of the first parameter, assuming you live in the U.S.
  352.  
  353.     Entering STRINGS BIOSDATE returns a string, normally containing thedate, from address F000:FFF5h in the BIOS ROM.  The command assumes thedate will be in the first 8 bytes following the address, as it is in most
  354. PC compatibles.  The command takes no arguments.
  355.  
  356.      The GETKEY command waits for the user to press a key then returns
  357. the ASCII value and its scan code.  While the ASK command is limited to
  358. returning ASCII characters, GETKEY is also able to return non-ASCII keys
  359. such as the cursor keys and function keys. The codes are returned with
  360. the ASCII code first, followed by a space, followed by the scan code.
  361. It is at this point that you can use the PARSE command to operate separately
  362. on the ASCII and scan codes returned by the keystroke.
  363.  
  364.     The next four commands--AND, OR, XOR, and NOT--extend the math commands
  365. to logical operations.  The AND command returns the logical AND of the
  366. parameters you supply.  Likewise, the OR and XOR commands return thelogical OR and exclusive OR of their respective parameters. Like the ADD,
  367. SUB, and MUL commands, the AND and OR commands can take up to ten
  368. parameters.  XOR, of course, takes only two. The NOT command returns the
  369. one's complement of its single parameter.
  370.  
  371.     The CONVERT command, which converts a number to a different base,
  372. became necessary once the /B switch was introduced.  This command takes
  373. two parameters:  the number to be converted and the new number base.
  374. As with all commands, both the number and new base parameters are
  375. interpreted in the base specified in the /B switch.  For example, to
  376. convert the hexadecimal (base 16) number 2FB to decimal, the command
  377. would be
  378.  
  379.                         STRINGS /B16 CONVERT 2FB, A
  380.  
  381. Note here that the second parameter, A, is not the character A, but rather
  382. the number 10, in hexadecimal.  Going the other way, the command
  383.  
  384.                         STRINGS CONVERT 763, 16
  385.  
  386. returns the hexadecimal number 2FB. (Because the default base for STRINGSis base 10, the /B switch is not required in this case.)
  387.  
  388. TIME & DATE COMMANDS
  389.  
  390.      The next four commands return times and dates.  The DAY function
  391. returns the current day of the week:STRINGS DAY will return Tuesday if
  392. today is Tuesday.  As an added feature, if the DAY command is passeda number between 1 and 7, it returns the day corresponding to that number.STRINGS DAY 6 returns the string Friday, for example.
  393.  
  394.     The MONTH command is entirely similar to the DAY command, and again,if passed a number between 1 and 12, it returns the month corresponding
  395. to that number.
  396.  
  397.     The DATE command returns the current date in a mm-dd-yyyy format.
  398. The Time command similarly returns the current time in a hh:mm:ss am/pm
  399. format. Users requiring a different format for the time and date can
  400. easily use the multitude of STRINGS commands to present the data in any
  401. form they wish.
  402.  
  403. SYSTEM MEMORY
  404.  
  405.      The enhanced STRINGS contains a number of commands that deal with
  406. system memory. MEMTOTAL returns the total conventional (DOS) memory
  407. available to the system, and MEMFREE returns the amount of conventional
  408. memory still available for use.  Note, however, that the MEMFREE command
  409. will respond differently when STRINGS is installed as resident.
  410. COMMAND.COM does not release its memory when resident commands are
  411. executed, so if STRINGS is resident when this call is made, the amount
  412. of free conventional memory indicated will be small or nonexistent.
  413.  
  414.     The XMSTOTAL command returns the total amount of extended memory inthe system, and XMSFREE returns the amount of free extended memory.
  415. Normally, extended memory is managed by an extended memory (XMS) manager,
  416. such as HIMEM.SYS.  If no XMS manager is present, STRINGS uses a BIOSInt 15h call to determine the amount of extended memory. In this case,
  417. as there is no memory manager present to differentiate between free and
  418. used extended memory, both the XMSFREE and XMSTOTAL calls will return
  419. the same number.  XMSVER returns the version of the XMS memory manager
  420. in use; if none is present, the command returns 0.
  421.  
  422.     Expanded memory is correspondingly queried with the EMSTOTAL, EMSFREE,
  423. and EMSVER commands. Again, if no expanded memory manager is installed,
  424. EMSVER will return 0.
  425.  
  426.      The final memory command is UMBLARGE.  This command returns the size
  427. of the largest free upper memory block (UMB).  UMBs are blocks of memory
  428. that reside between the video memory at A000h and the BIOS ROM at E000h
  429. or F000h.  This command is useful for determining whether there is room
  430. in upper memory for TSRs.
  431.  
  432. PROGRAMMER'S COMMANDS
  433.  
  434.      The next series of commands are designed for the PC programmer.
  435. They allow batch files to actually perform functions previously reserved
  436. for .COM and .EXE files.
  437.  
  438.      PEEK, the first of these commands, allows a batch file to read a
  439. series of bytes from memory.  The syntax of the PEEK command is
  440.  
  441. STRINGS [dest var=] PEEK Segment, Offset [,Number of bytes] [,Word flag]
  442.  
  443.      The first two command parameters are the segment and offset of the
  444. memory address to be read.  The optional third parameter is the number
  445. of bytes to be read; if this parameter absent, STRINGS returns 1 byte.
  446. The fourth and final parameter is also optional.  If it is 2, STRINGSwill return the bytes read from memory in a 2-byte, or word, format.
  447.  
  448.     To illustrate, in order to see which shift keys are pressed, you
  449. can use the PEEK command to read the keyboard status bytes at 40:17 and
  450. 40:18 hex.  The command would be
  451.  
  452.                                  STRINGS /b16 PEEK 40, 17, 2.
  453.  
  454.      The complementary POKE command writes data directly to memory.
  455. Again, the first parameter is the segment and the second is the offset
  456. of the address.  The remaining parameters, up to an additional eight,
  457. are the bytes to write to memory. Note that while these bytes are beingwritten, interrupts are disabled so the system doesn't read partially
  458. written data. The following short batch file uses the PEEK, AND, and
  459. POKE commands to turn off the keyboard NumLock.
  460.  
  461.                        STRINGS /b16 shift = PEEK 40, 17
  462.                        STRINGS /b16 shift = AND %SHIFT%, DF
  463.                        STRINGS /b16 POKE 40, 17, %SHIFT%
  464.                        SET shift=
  465.  
  466.      You could also use the POKE command to overwrite the DOS command
  467. interrupt vector (Interrupt 21) with zeros, the command would be
  468.  
  469.                        STRINGS /B16 POKE 0, 84, 0, 0, 0,0
  470.  
  471. Don't try this example, however, for it will surely lock up your machine!
  472. As this last example illustrates, POKE--and other programming commands
  473. that will be discussed shortly--can easily be misused and thereby cause
  474. harm.  So make sure you fully understand a command before you use it.
  475.  
  476.     The IN and OUT commands give batch files the ability to read and
  477. write to system I/O (Input/Output) ports. It is through these ports that
  478. the system talks to disk drive controllers and to devices connected to
  479. serial and/or parallel ports. The IN command takes only one parameter,
  480. namely, the address of the I/O port. This address is the first of the
  481. OUT command's two parameters, the second being the data byte to write
  482. to that port.
  483.  
  484.     An amusing example that demonstrates the use of the IN and OUT
  485. commands is provided by the batch files NOIZE and MARY, which are listed
  486. below in Figure 4.  NOIZE.BAT plays a note on the PC speaker by toggling
  487. the speaker control bits in the keyboard control I/O port (I/O address 61h).
  488. The proper timing for the note is determined by using PC hardware timer 3.
  489. MARY.BAT calls NOIZE.BAT to play the familiar ``Mary had a little lamb.''
  490. My thanks to Neil Rubenking for this entertaining example.
  491.  
  492.     The INTERRUPT command is easily the most powerful--and therefore
  493. dangerous--command in the STRINGS repertoire. The command calls an
  494. interrupt and returns the values of the registers. The ten parameters for
  495. this command specify the interrupt number and the values of most of the
  496. processor registers at the time the interrupt is called.  Its syntax is
  497. the following:
  498.  
  499.      STRINGS INTERRUPT Int Number, AX, BX, CX, DX, DI, SI, BP, DS, ES
  500.  
  501.     The string returned is a series of numbers, separated by spaces,
  502. that represent the value in each of the registers at the time the
  503. interrupt returns.  The format for the returned string is
  504.  
  505.                   AX BX CX DX DI SI BP DS ES Flags
  506.  
  507.     The Flags register contains such flags as Carry, Zero, Sign, and
  508. Interrupt Enable.  Just as a value is returned for each of the other
  509. registers, a value is also returned for the Flags register.  It is the
  510. responsibility of the batch program to examine the value returned for
  511. the Flags register to determine the state of any flags that might be
  512. important.  For this purpose, the AND and OR commands often prove useful.
  513.  
  514.     An example of this complex command in action will be helpful. Suppose
  515. you want to know the address of the InDOS flag.  The newly documented
  516. function for getting the InDOS address is Interrupt 21, AH = 34.  The
  517. STRINGS command to enter would be 
  518.  
  519.         STRINGS /B16 INTERRUPT 21, 3400, 0, 0, 0, 0, 0, 0, 0, 0
  520.  
  521.     The /B16 switch is used to tell STRINGS to ``talk'' in hexadecimal,
  522. which is handy because most PC programming is done in base 16.  The 21
  523. indicates that you want STRINGS to call Interrupt 21h, the DOS command
  524. dispatcher.  The 3400 indicates that AX is to be loaded with 3400h when
  525. the interrupt is called.  In fact, you only need to load AH (with 34h),
  526. but the command has no way of loading the individual byte halves of the
  527. registers.  Thus, you end up loading AX with 3400, which puts 34 in AH
  528. and 00 in AL.  The remaining registers for this interrupt are not
  529. important, and actually they don't have to be included at all. STRINGS
  530. loads 0 in the registers not specified.
  531.  
  532.     On my machine running MS-DOS 5.0, the command above returns thestring
  533.  
  534.           3400 321 0 0 0 0 0 0 116 7246
  535.  
  536. The INTERRUPT command always returns a string with ten numbers, each
  537. separated by a space.  Because the /B16 switch was used, all the values
  538. are in hexadecimal.  The first number, 3400, is the value of the AX
  539. register when the interrupt returns.  The important values, however,
  540. are 321, the value of BX on the return; and 116, which is the returned
  541. value of ES.  The MS-DOS Programmer's Reference indicates that the address
  542. of the InDOS flag will be returned in ES:BX.
  543.  
  544.     You can now use the PEEK command to check the state of the InDOS
  545. flag.  That command would look like this:
  546.  
  547.                        STRINGS /B16 PEEK 116 321
  548.  
  549.     Although knowing the address of the InDOS flag has little use for
  550. batch file programming, other interrupts can come in quite handy.  The
  551. undocumented interrupt 21 AX=5200 returns a pointer to DOS's list of
  552. lists. This pointer is quite useful for checking out the current stateof the machine.  Shortly I'll present a batch file that uses the list of
  553. lists to determine the current memory usage for the system.
  554.  
  555.     The final programmer's command is SCAN. This command searches memoryfor a series of bytes.  The segment to search and the starting offset
  556. are specified in the first two parameters.  The remaining parameters
  557. (up to an additional eight) are the bytes to use in the search.
  558. For example, to search the segment 23h for the byte series 10 20 30 40
  559. the command would be
  560.  
  561. STRINGS /B16 SCAN 23, 0, 10, 20, 30, 40
  562.  
  563. Since SCAN searches only the segment specified, additional SCAN commandsare needed for any searches beyond the original segment.
  564.  
  565.     When used in conjunction with the improved VAL command, SCAN cansearch for an ASCII string in memory. An example is shown in the followingbatch code fragment, which searches the DOS kernel for the string ``NUL":
  566.  
  567. STRINGS /B16 VALSTR = VAL NUL 
  568. STRINGS /B16 /P SCAN 116 0 %VALSTR%
  569.  
  570.     As previously discussed, the VAL command returns the ASCII numbers
  571. for each of the characters in the first parameter. In this case, because
  572. the /B16 switch is used, VAL returns the numbers 4E 55 4C as a series of
  573. hex bytes.  These bytes are assigned to the VALSTR environment variable.
  574. The new InDOS command mentioned above starts at offset 0 and uses the
  575. VALSTR environment variable for its remaining arguments.  On my machine,
  576. this fragment returns the address 116 52, which is the address for theNUL device driver name.  That address is important because the NUL devicedriver is the first in the DOS device driver chain.
  577.  
  578.     Two additional notes about this batch fragment are in order.  First,
  579. the lack of commas separating the parameters in the SCAN command is not
  580. a typo.  The /P switch is used here to change the parse character to a
  581. space.  This is convenient, since the VAL command returns its numbers
  582. separated by spaces.
  583.  
  584.     The second important detail concerns the consistent use of the /B
  585. switch.  While it may not seem that the /B switch would be needed for
  586. either command, if it is used in the VAL command it must be used in the
  587. SCAN command.  Since VAL uses a /B16 switch, it returns its numbersin hex.  Because the result from the VAL command is used in the SCAN
  588. command, SCAN must use the same base.  Why was the /B16 switch used in
  589. the first place? Remember that the DOS segment returned by the INTERRUPT
  590. command was returned in hexadecimal, which forced the use of the /B
  591. switch since we used that number.  Just follow this simple rule:  If
  592. parameters are shared across STRINGS commands, they should use the same
  593. base, or you should use the CONVERT command to change the parameters
  594. to the proper base.
  595.  
  596. STRINGS MANAGEMENT
  597.  
  598.      The final group of new STRINGS commands are to manage STRINGS itself.
  599. STRINGSVER returns the version of STRINGS currently being used.  Since
  600. this command did not exist in the first version of STRINGS, calling it
  601. with STRINGS1 will result in an error message and a return code of 1.
  602. If STRINGSVER returns a nonzero ERRORLEVEL code, then STRINGS 1.x is
  603. running.  For the present version of STRINGS, the STRINGSVER command
  604. returns the ASCII string 200 and a return code of 0.
  605.  
  606.     The INSTALLED command returns a 1 if STRINGS is currently installed
  607. as a TSR extension to COMMAND.COM. If STRINGS is not installed, a 0 is
  608. returned.  This command is useful for those situations in which a
  609. STRINGS command might produce different results if the utility were
  610. installed.  MEMFREE represents one such case, and the use of returncodes may be another.
  611.  
  612. INSIDE STRINGS
  613.  
  614.      For the most part, the enhanced version of strings simply involved
  615. adding procedures for the new functions. The main change to the program
  616. itself was the rewriting of the command parsing routine to use less memory.This was necessary so that STRINGS could be turned into a TSR. Of greatestprogramming interest, however, is the hook into COMMAND.COM's internalcommand dispatcher.
  617.  
  618.     In Undocumented DOS, coauthor Jim Kyle has an informative chapter oncommand interpreters. It describes an undocumented ``back door'' into
  619. COMAND.COM that allows TSRs to hook into the internal command dispatcher.This back door was first included in DOS 3.3 so that DOS's APPEND commandcould check on any subsequent APPEND commands. Fortunately for programmers,
  620. that door has remained open in all later DOS releases.
  621.  
  622.     When you enter a command at the DOS command line, COMMAND.COM must
  623. determine whether the command is an internal function to be executed or
  624. an external program that must be launched. Before making its decision,
  625. COMMAND.COM calls the Multiplex Interrupt (Int 2Fh) with AX equal to
  626. AE00h. At the time of the call, DX is loaded with FFFFh, BX is pointing
  627. to a buffer that contains an exact replica of the command line just typed,
  628. and SI points to a buffer that contains the potential command in
  629. uppercase preceeded by a length byte.
  630.  
  631.     TSRs such as STRINGS that hook into this call must compare the
  632. command to which SI points with the command they wish to handle. For
  633. STRINGS, that means checking to see whether SI is pointing to the ASCII
  634. string "STRINGS".
  635.  
  636.     A TSR that wants to claim the command puts 0FFh in AL, copies the
  637. comand line pointed to by BX into an internal buffer, and returns to
  638. COMMAND.COM.  Otherwise the TSR must pass the Multiplex request down
  639. the interrupt chain with all registers unmodified.
  640.  
  641.     If a TSR claims the command, COMMAND.COM calls the Multiplex
  642. Interrupt again, this time with AX loaded with AE01h.  Having claimed it,
  643. the TSR must now execute the command.  While most of the registers during
  644. this call are the same as in the AE00h call, Kyle recommends that a TSR
  645. should copy the buffer from the earlier AE00h call because not all the
  646. registers are explicitly loaded before the AE01h call.  Once the commandhas been completed, the TSR should zero the size byte in the buffer to
  647. which SI points.  This tells COMMAND.COM that the command has been
  648. processed.
  649.  
  650.     While STRINGS doesn't provide every possible function a batch file
  651. might want, the inclusion of such commands as PEEK, POKE, and INTERRUPT
  652. allow the programmer to create just about any command.  An an example of
  653. this power is shown in BATMEM.BAT, which is listed below in Figure 5.
  654.  
  655.     BATMEM scans the DOS memory blocks and displays the blocks that arebeing used as well as the ones that are free. BATMEM is similar to the
  656. MEM command that has been included in DOS since version 4.0.  Among the
  657. STRINGS functions BATMEM uses are INTERRUPT, PARSE, CHAR, PEEK, andADDCOMMAS.
  658.  
  659.     Notice that in BATMEM, STRINGS is installed with /I at the beginning
  660. of the batch file and removed with /U at the end. These two switches double
  661. the execution speed.  If you don't want STRINGS installed and removed,
  662. simply delete the /I and /U switches; the remainder of the batch file
  663. will be unaffected.
  664.  
  665.     Programs like BATMEM give but a taste of the world STRINGS opens to
  666. enterprising batch file writers.  To supplement STRINGS own commands, you
  667. may wish to acquire Michael J. Mefford's excellent BATCHMAN utility in
  668. the January 30, 1990 issue of PC Magazine. Like STRINGS, BATCHMAN is
  669. available on PC MagNet.
  670.  
  671.     The ability to perform low-level actions, coupled with the convenient
  672. features of STRINGS's high-level commands, provide a wealth of new
  673. opportunities for the once-lowly batch file. Try STRINGS, and your batch
  674. files will never be the same.
  675. ----------------------------------------------------------------------------DOUGLAS BOLING IS A CONTRIBUTING EDITOR TO PC MAGAZINE.
  676. ----------------------------------------------------------------------------
  677.  
  678.                        STRINGS COMMANDS
  679.  
  680.  
  681.              FUNCTION AND SYNTAX                 RETURNS
  682.  
  683.  
  684. New          2FCHECK n or Alias              Returns status of programs hooked
  685.                                              to the Multiplex Interrupt.
  686.  
  687. Enhanced     ADD n1, n2[,n3][,n4][,n5]       The sum of the parameters.
  688.              [,n6][,n7][,n8][,n9][,n10]
  689.  
  690. New          ADDCOMMAS n                     n parsed with commas every 3
  691.                                              digits.
  692.  
  693. New          AND n1, n2[,n3][,n4][,n5]       The logical AND of the
  694.              [,n6][,n7][,n8][,n9][n10]       parameters.
  695.  
  696. Enhanced     ASK [Prompt string]
  697.              [, Max chars][,1=No echo]       A response from a user.
  698.  
  699. New          BIOSDATE                        The date for the ROM BIOS.
  700.  
  701. Enhanced     CHAR c[c][c][c][c]
  702.              [c][c][c][c][c][c]              ASCII number of character.
  703.  
  704. New          CODEPAGE                        The activecode page.
  705.                                              Requires DOS 3.3 or later.
  706.  
  707. New          CONVERT n, New Base             A number with the specified
  708.                                              base.
  709.  
  710. New          COUNTRY                         The country code for the
  711.                                              system.
  712.  
  713. New          DATE                            The current date in mm-dd-yyyy
  714.                                              format.
  715.  
  716. New          DAY [Index (1=Sunday, 2=Mon]    The name of the day of the
  717.                                              week.
  718.  
  719.              DIV n, n                        The quotient of two numbers.
  720.  
  721. New          EMSFREE                         The amount of free expanded
  722.                                              memory.
  723.  
  724. New          EMSTOTAL                        The amount of expanded memory.
  725.  
  726. New          EMSVER                          The version of the expanded
  727.                                              memory driver.
  728.  
  729.              ENVFREE                         Bytes free in the environment.
  730.  
  731.              ENVSIZE                         The size of the environment.
  732.  
  733. New          FILEDATE Filename               The date of a file.
  734.  
  735.              FILEDIR Filename                The directory of a filename.
  736.  
  737.              FILEDRIVE Filename              The drive of a filename.
  738.  
  739.              FILEEXT Filename                The file extension.
  740.  
  741.              FILENAME Filename               The filename.
  742.  
  743. New          FILES                           The total number of files that
  744.                                              can be open.
  745.  
  746.              FILESIZE Filename               The size of a file.
  747.  
  748. New          FILETIME Filename               The time of a file.
  749.  
  750.              FIND String, Findstring         The position of Findstring in
  751.                                              String.
  752.  
  753.              FINDC String, Findstring        The position of Findstring
  754.                                              in String. Case sensitive.
  755.  
  756. New          GETKEY                          The scan code and ASCII value of
  757.                                              next key pressed.
  758.  
  759. New          HELP [Strings Command]         The help text for the specified
  760.                                              STRINGS command.
  761.  
  762. New          IN Port number                  A byte from an I/O port.
  763.  
  764. New          INSTALLED                       A non-zero number if Strings
  765.                                              installed as TSR.
  766.  
  767. New          INTERRUPT Int n, AX, BX, CX,
  768.          DX, DI, SI, BP, DS, ES         The registers from an interrupt.
  769.                                              Dangerous!
  770.  
  771.              INWIN                     1 if Windows running.
  772.  
  773. New          LASTDRIVE                       The letter of the last possible
  774.                                              drive.
  775.  
  776.              LEFT String, n                  The left n characters.
  777.  
  778.              LENGTH String                   The String length.
  779.  
  780.              LINESIZE Filename               The number of lines.
  781.  
  782.              LOWER String                    The string in all lowercase.
  783.  
  784.              MASTERENV                       The address of the master
  785.                                              environment
  786.  
  787.          MASTERVAR Variable Name         A variable from the Master
  788.                                              environment.
  789.  
  790. New          MEMFREE                         The largest block of free
  791.                                              conventional memory.
  792.  
  793. New          MEMTOTAL                        The amount of conventional
  794.                                              memory.
  795.  
  796.              MID String, Start c, Length     The middle n characters.
  797.  
  798. New          MONTH [Index (1=January)]       The name of the month
  799.  
  800. Enh          MUL n1, n2[,n3][,n4][,n5]
  801.              [,n6][,n7][,m8][,n9][,n10]      The product of the parameters.
  802.  
  803. New          NOT n                           The logical NOT of n.
  804.  
  805. New          OR n1, n2[,n3][,n4][,n5]
  806.              [,n6][,n7][,n8][,n9][,n10]      The logical OR of the parameters.
  807.  
  808. New          OUT Port n, Output byte         Writes a byte to an I/O port.
  809.  
  810. New          PARSE String, Token n,
  811.              Token separator char            The nth token from a string.
  812.  
  813. New          PEEK Segment, Offset
  814.              [, n bytes [,Word flag]]        A series of bytes from memory.
  815.  
  816. New          POKE Segment, Offset,
  817.              b1[,b2][,b3][,b4]
  818.              [,b5][,b6][,b7][,b8]            Writes up to 8 bytes to memory.
  819.  
  820.  
  821.              READ Filename, line number      A line from a file.
  822.  
  823. New          REPEAT n of chars, c            A string of n characters c.
  824.  
  825.              RIGHT String, n                 The right n characters.
  826.  
  827. New          SCAN Segment, Starting
  828.              Offset, b1 [,b2]                The offset of a series of
  829.                                              bytes in memory.
  830.  
  831. Enh          SUB n1, n2[,n3][,n4][,n5]
  832.              [,n6][,n7][,n8][,n9][,n10]      The difference of two numbers.
  833.  
  834. New          TIME                            The current time.
  835.  
  836.              TRUENAME Filename               The complete filename.
  837.  
  838. New          TRUEVER                         The true DOS verison.
  839.                                              Requires DOS 5.0 or later.
  840.  
  841. New          UMBLARGE                        The largest block of free
  842.                                              upper memory.
  843.  
  844.              UPPER String                    The string in all uppercase.
  845.  
  846. Enh          VAL n1, n2[,n3][,n4][,n5]
  847.              [,n6][,n7][,n8][,n9][,n10]      ASCII characters for a number.
  848.  
  849.              VER                             The DOS version number.
  850.  
  851.              WRITE Filename, String         Appends a string to the end
  852.                                              of a file.
  853.  
  854. New          XMSFREE                         The amount of free extended
  855.                                              memory.
  856.  
  857. New          XMSTOTAL                        The amount of extended memory.
  858.  
  859. New          XMSVER                          The version of the extended
  860.                                              memory driver.
  861.  
  862. New          XOR n, n                        The exclusive OR of two numbers.
  863.  
  864. Figure 1:
  865. All commands shown above begin with STRINGS [dest var =].  In the listing, n
  866. designates a number, c a character, and b a byte.
  867. ----------------------------------------------------------------------------
  868.  
  869. CHECKEX.BAT
  870.  
  871. rem----------------------------------------------------
  872. rem CHECKEX.BAT - Scans the path for a program name.
  873. rem----------------------------------------------------
  874. @echo off
  875. SET index=1
  876. if exist %1.com echo %1.com
  877. if exist %1.exe echo %1.exe
  878. if exist %1.bat echo %1.bat
  879. :loop
  880.    STRINGS pdir = PARSE %path%, %index%,;
  881.    IF . == .%pdir% GOTO exit
  882.    if exist %pdir%\%1.com echo %pdir%\%1.com
  883.    if exist %pdir%\%1.exe echo %pdir%\%1.exe
  884.    if exist %pdir%\%1.bat echo %pdir%\%1.bat
  885.    STRINGS index = ADD %index%, 1
  886. GOTO loop
  887. :exit
  888. SET index=
  889. SET pdir=
  890.  
  891. Figure 2: CHECKEX.BAT shows the execution priority order for a program
  892. name that might be present on a path in .COM, .EXE, and .BAT forms.
  893. ------------------------------------------------------------------------
  894.  
  895.                       COUNTRY CODES
  896.  
  897. ==================================================================
  898.  
  899. First Parameter Value   Returns                  Comments
  900. --------------------------------------------------------------------
  901. No parameter            Country Code             Active country code
  902. 0                       Date Format              0 = mm-dd-yyyy
  903. 1                       Currency Symbol          $ for the US
  904. 2                       Thousands Separator      , for the US
  905. 3                       Decimal Separator        . for the US
  906. 4                       Date Separator           - for the US
  907. 5                       Time Separator           : for the US
  908. 6                       Currency Format          0 for the US
  909. 7                       Currency Places          2 for the US
  910. 8                       Time Format              0 = 12-hour format
  911. 9                       Data Separator           , for the US
  912.  
  913.  
  914. Figure 3: These are the different values returned when 1 is supplied as
  915. the parameter for the COUNTRY command.
  916. ------------------------------------------------------------------------
  917.  
  918.  
  919. NOIZE.BAT
  920.  
  921. @ECHO OFF
  922. REM ------------------------------------------------------------
  923. REM NOIZE.BAT - by Neil Rubenking
  924. REM
  925. REM Enter a frequency as its command line parameter and it
  926. REM starts a note of that frequency.  Enter NO parameter and it
  927. REM shuts the speaker up.
  928. REM ------------------------------------------------------------
  929. IF '%1'=='' GOTO Stop
  930. STRINGS inv=DIV 1193180,%1
  931. STRINGS inv=CONVERT %inv%,16
  932. STRINGS inv=RIGHT 0000%inv%,4
  933. STRINGS Hi=LEFT %inv%,2
  934. STRINGS Lo=RIGHT %inv%,2
  935. STRINGS /b16 OUT 43,B6
  936. STRINGS /b16 OUT 42,%lo%
  937. STRINGS /b16 OUT 42,%hi%
  938. STRINGS /b16 AL=IN 61
  939. STRINGS /b16 AL=OR %AL%,3
  940. STRINGS /b16 OUT 61,%AL%
  941. GOTO End
  942. :Stop
  943. STRINGS /b16 AL=IN 61
  944. STRINGS /b16 AL=AND %AL%,FC
  945. STRINGS /b16 OUT 61,%AL%
  946. :End
  947. SET al=
  948. SET inv=
  949. SET hi=
  950. SET lo=
  951.  
  952. @ECHO OFF
  953. REM ------------------------------------------------------------
  954. REM MARY.BAT - by Neil Rubenking
  955. REM
  956. REM Plays a familar tune
  957. REM ------------------------------------------------------------
  958. STRINGS /I /Q
  959. CALL NOIZE 330
  960. CALL NOIZE 294
  961. CALL NOIZE 262
  962. CALL NOIZE 294
  963. CALL NOIZE 330
  964. CALL NOIZE 330
  965. CALL NOIZE 330
  966. CALL NOIZE 330
  967. CALL NOIZE 294
  968. CALL NOIZE 294
  969. CALL NOIZE 294
  970. CALL NOIZE 294
  971. CALL NOIZE 330
  972. CALL NOIZE 392
  973. CALL NOIZE 392
  974. CALL NOIZE 392
  975. CALL NOIZE
  976. STRINGS /U /Q
  977.  
  978. Figure 4: NOIZE.BAT and MARY.BAT combine to play "Mary Had a Little Lamb."
  979. --------------------------------------------------------------------------
  980.  
  981. BATMEM.BAT
  982.  
  983. @echo off
  984. rem -------------------------------------------------------------
  985. rem
  986. rem A batch file that returns a memory scan
  987. rem BATMEM.BAT
  988. rem Copyright 1992 Douglas Boling
  989. rem
  990. rem -------------------------------------------------------------
  991. rem
  992. rem First, get the pointer to the list of lists
  993. rem
  994. strings /i /b16 iret = interrupt 21, 5200
  995. strings /b16 lloff = parse %iret%, 2
  996. strings /b16 llseg = parse %iret%, 9
  997. set iret=
  998.  
  999. rem
  1000. rem First memory block kept at ListOfList - 2
  1001. rem
  1002. strings /b16 lloff = sub %lloff%, 2
  1003. strings /b16 memseg = peek %llseg%, %lloff%, 2, 2
  1004.  
  1005. echo.
  1006. echo  Block Owner Size Program
  1007. echo  --------------------------------
  1008.  
  1009. strings /b16 totalmem = add %memseg%, 1
  1010. set freemem=0
  1011. :loop
  1012.    rem
  1013.    rem Parse the memory arena header
  1014.    rem
  1015.    strings /b16 memtype = peek %memseg%, 0, 1
  1016.    strings /b16 memowner = peek %memseg%, 1, 2, 2
  1017.    strings /b16 memsize = peek %memseg%, 3, 2, 2
  1018.  
  1019.    strings /b16 memtemp = peek %memseg%, 8, 8
  1020.    strings /b16 /p  memtemp = char %memtemp%
  1021.  
  1022.    strings /b16 memseg = add %memseg%, 1
  1023.    rem
  1024.    rem If block not PSP, don't print block name
  1025.    rem
  1026.    set memname=
  1027.    set diff=-1
  1028.  
  1029.    strings /b16 /q diff = sub %memseg%, %memowner%
  1030.    if .%diff% == .0 goto skip1
  1031.    goto skip2
  1032.    :skip1
  1033.       set memname=%memtemp%
  1034.    :skip2
  1035.  
  1036.    if NOT %memowner% == 0000 goto skip3
  1037.       set memowner=FREE
  1038.       strings /b16 freemem = add %freemem%, %memsize%
  1039.    :skip3
  1040.    rem
  1041.    rem OK, print the results
  1042.    rem
  1043.    echo  %memseg% %memowner% %memsize% %memname%
  1044.  
  1045.    strings /b16 memseg = add %memseg%, %memsize%
  1046.    strings /b16 totalmem = add %memsize%, %totalmem%
  1047.    strings /b16 totalmem = add %totalmem%, 1
  1048.  
  1049. if %memtype% == 4D goto loop
  1050.  
  1051. echo.
  1052.  
  1053. strings /b16 memsize = mul %memsize%, 10
  1054. strings /b16 memsize = convert %memsize%, A
  1055. strings memsize = addcommas %memsize%
  1056.  
  1057. strings /b16 totalmem = mul %totalmem%, 10
  1058. strings /b16 totalmem = convert %totalmem%, A
  1059. strings /u totalmem = addcommas %totalmem%
  1060.  
  1061. echo  %totalmem% bytes total conventional memory
  1062. echo  %memsize% largest program executable size
  1063. echo.
  1064. rem
  1065. rem Done, clean up all vars
  1066. rem
  1067. set llseg=
  1068. set lloff=
  1069. set memseg=
  1070. set memowner=
  1071. set memsize=
  1072. set memtype=
  1073. set memname=
  1074. set memtemp=
  1075. set freemem=
  1076. set totalmem=
  1077. set diff=
  1078.  
  1079. Figure 5: BATMEM.BAT produces a list of the DOS memory segments.
  1080. ------------------------------------------------------------------------